#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	if (s1.size() > s2.size()) swap(s1, s2);
	string res;
	int l = 0;
	for (int i = 0;i < s1.size();i++)
	{
		for (int j = i + 1;j <= s1.size();j++)
		{
			if (s2.find(s1.substr(i, j - i)) != s2.npos)
			{
				l = max(l, j - i);
			}
		}
	}
	cout << l << endl;
	return 0;
}